<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head> 

        <h:body>
            <ui:composition template="./template.xhtml">
                <ui:define name="top">

                </ui:define>
                <ui:define name="left">
                    <h:form >

                        <p:menu my="true" style="width:200px">
                            <p:submenu label="Navigation Employé" >  
                                <p:menuitem value="Les employés" action="#{redirectionBean.getRedirectionListeAmploye}" icon="ui-icon-home"
                                            styleClass="#{view.viewId == '/listeTravailleur.xhtml' || 
                                                          view.viewId == '/ajouterUnTravailleur.xhtml' || 
                                                          view.viewId == '/detailTravailleur.xhtml' ||
                                                          view.viewId == '/editerUnTravailleur.xhtml' ? 'ui-state-active' : ''}"
                                            />  

                            </p:submenu>
                            <p:submenu label="Navigation Mission">  
                                <p:menuitem value="Gestion des missions" action="#{redirectionBean.getRedirectionGestionMission}" icon="ui-icon-suitcase" 
                                            styleClass="#{view.viewId == '/gestionMission.xhtml' ? 'ui-state-active' : ''}"
                                            />   
                            </p:submenu>  
                            <p:submenu label="Navigation Réglage">  
                                <p:menuitem value="Réglage formulaire" action="#{redirectionBean.getRedirectionGeglageformulaire}" icon="ui-icon-gear"
                                            styleClass="#{view.viewId == '/reglageformulaire.xhtml' ? 'ui-state-active' : ''}"
                                            />  
                            </p:submenu>  
                        </p:menu> 

                    </h:form>
                </ui:define>

                <ui:define name="content">
                    <h:form id="formMessage">
                        <p:growl id="message" showDetail="true" />
                    </h:form>
                    <h:form id="formeReglageFormulaire">
                        <p:panel header="Reglage" style="width: 95%">
                            <f:facet name="header">
                                Renseigner, modifier les informations dans les formulaires
                            </f:facet>
                            <p:tabView id="tabView">  

                                <p:tab id="tab1" title="Compagnie">  
                                    <h:panelGrid columns="2" > 
                                        <p:dataTable var="compagnie" value="#{reglageFormulaireBean.cvCompagnieSelect}" id="compagnieList" editable="true">  

                                            <f:facet name="header">  
                                                Liste des compagnies 

                                            </f:facet>  

                                            <p:ajax event="rowEdit" listener="#{reglageFormulaireBean.onEditCVCompagnie}" update=":formMessage:message" />  
                                            <p:ajax event="rowEditCancel" listener="#{reglageFormulaireBean.onCancel}" update=":formMessage:message" />  

                                            <p:column headerText="Nom de la compagnie" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{compagnie.nomcompagnie}" />  
                                                    </f:facet>  
                                                    <f:facet name="input">  
                                                        <p:inputText value="#{compagnie.nomcompagnie}" style="width:100%"/>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>
                                            <p:column headerText="Activé" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{compagnie.active == true ? 'Oui' : 'Non'}" styleClass="#{compagnie.active == true ? 'verte':'rouge'}"/>  
                                                    </f:facet>  
                                                    <f:facet name="input">
                                                        <h:selectOneMenu value="#{compagnie.active}" >  
                                                            <f:selectItems value="#{reglageFormulaireBean.choix}"  
                                                                           var="elementActivation"   
                                                                           itemLabel="#{elementActivation.nom}"  
                                                                           itemValue="#{elementActivation.etat}" />  
                                                        </h:selectOneMenu>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>

                                            <p:column headerText="Modifié" style="width:6%">  
                                                <p:rowEditor />  
                                            </p:column>
                                        </p:dataTable> 
                                        <h:panelGrid columns="2" style="margin-left: 50px;">  

                                            <h:form id="formNouveauCompagnie">
                                                <p:panel header="Nouvelle compagnie">
                                                    <h:panelGrid columns="2">
                                                        <h:outputLabel value="Nom de la compagnie:" for="nomcompagnie" />
                                                        <p:inputText id="nomcompagnie" required="true" 
                                                                     value="#{reglageFormulaireBean.cvCompagnie.nomcompagnie}" title="Nomcompagnie" />
                                                        <h:outputText />
                                                        <p:commandButton value="Créer" icon="ui-icon-check"
                                                                         update=":formeReglageFormulaire:tabView:formNouveauCompagnie, :formeReglageFormulaire:tabView:compagnieList, :formMessage:message"
                                                                         action="#{reglageFormulaireBean.creerCompagnie}"
                                                                         /> 
                                                    </h:panelGrid>
                                                </p:panel>
                                            </h:form>

                                        </h:panelGrid>
                                    </h:panelGrid>  
                                </p:tab>  

                                <p:tab id="tab6" title="Mission">  
                                    <h:panelGrid columns="2">  
                                        <p:dataTable var="mission" value="#{reglageFormulaireBean.listCvMissions}" id="missionList" editable="true">  

                                            <f:facet name="header">  
                                                Liste des missions 

                                            </f:facet>  

                                            <p:ajax event="rowEdit" listener="#{reglageFormulaireBean.onEditCVMission}" update=":formMessage:message" />  
                                            <p:ajax event="rowEditCancel" listener="#{reglageFormulaireBean.onCancel}" update=":formMessage:message" />  

                                            <p:column headerText="Nom mission" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{mission.nomMission}" />  
                                                    </f:facet>  
                                                    <f:facet name="input">  
                                                        <p:inputText value="#{mission.nomMission}" style="width:100%"/>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>
                                            <p:column headerText="Activé" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{mission.active == true ? 'Oui' : 'Non'}" styleClass="#{mission.active == true ? 'verte':'rouge'}" />  
                                                    </f:facet>  
                                                    <f:facet name="input">
                                                        <h:selectOneMenu value="#{mission.active}" >  
                                                            <f:selectItems value="#{reglageFormulaireBean.choix}"  
                                                                           var="elementActivation"   
                                                                           itemLabel="#{elementActivation.nom}"  
                                                                           itemValue="#{elementActivation.etat}" />  
                                                        </h:selectOneMenu>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>

                                            <p:column headerText="Modifié" style="width:6%">  
                                                <p:rowEditor />  
                                            </p:column>
                                        </p:dataTable>
                                    </h:panelGrid>  
                                </p:tab>  
                                <p:tab id="tab2" title="Type de Poste">  
                                    <h:panelGrid columns="2">  
                                        <p:dataTable var="poste" value="#{reglageFormulaireBean.listCvListeposte}" id="postList" editable="true">  

                                            <f:facet name="header">  
                                                Liste des types de poste 

                                            </f:facet>  

                                            <p:ajax event="rowEdit" listener="#{reglageFormulaireBean.onEditCVPoste}" update=":formMessage:message" />  
                                            <p:ajax event="rowEditCancel" listener="#{reglageFormulaireBean.onCancel}" update=":formMessage:message" />  

                                            <p:column headerText="Nom mission" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{poste.poste}" />  
                                                    </f:facet>  
                                                    <f:facet name="input">  
                                                        <p:inputText value="#{poste.poste}"/>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>
                                            <p:column headerText="Activé" style="width:30%">  
                                                <p:cellEditor>  
                                                    <f:facet name="output">  
                                                        <h:outputText value="#{poste.active == true ? 'Oui' : 'Non'}" styleClass="#{poste.active == true ? 'verte':'rouge'}" />  
                                                    </f:facet>  
                                                    <f:facet name="input">
                                                        <h:selectOneMenu value="#{poste.active}" >  
                                                            <f:selectItems value="#{reglageFormulaireBean.choix}"  
                                                                           var="elementActivation"   
                                                                           itemLabel="#{elementActivation.nom}"  
                                                                           itemValue="#{elementActivation.etat}" />  
                                                        </h:selectOneMenu>  
                                                    </f:facet>  
                                                </p:cellEditor>
                                            </p:column>

                                            <p:column headerText="Modifié" style="width:6%">  
                                                <p:rowEditor  rendered="#{poste.idposte == 'chauffeurvl' || poste.idposte == 'chauffeurpl' ? 'false' : 'true'}"/>  
                                            </p:column>
                                        </p:dataTable>

                                        <h:panelGrid columns="1" style="margin-left: 50px;">
                                            <div class="alert alert-danger"><strong><u>Important :</u></strong> 
                                                <p>
                                                    Abstenez vous de modifier les postes <strong>chauffeur PL et VL </strong>
                                                    car ils sont utilisés par l'application radio opérateur pour identifier les chauffeurs.
                                                </p>

                                            </div>
                                            <h:form id="formNouvellePoste">
                                                <p:panel header="Nouveau type de poste">
                                                    <h:panelGrid columns="2">
                                                        <h:outputLabel value="Nom du type de poste :" for="nomposte" />
                                                        <p:inputText id="nomposte" required="true" 
                                                                     value="#{reglageFormulaireBean.cvListeposteNew.poste}" title="Description du poste" />

                                                        <h:outputText />

                                                        <p:commandButton value="Créer" icon="ui-icon-check"
                                                                         update=":formeReglageFormulaire:tabView:formNouvellePoste, :formeReglageFormulaire:tabView:postList, :formMessage:message"
                                                                         action="#{reglageFormulaireBean.creerPoste}"
                                                                         /> 
                                                    </h:panelGrid>
                                                </p:panel>
                                            </h:form>
                                            
                                        </h:panelGrid>  
                                    </h:panelGrid>  
                                </p:tab>  

                                <p:tab id="tab4" title="Type de Contrat">  
                                    <h:panelGrid columns="2" >  

                                    </h:panelGrid>  
                                </p:tab>   

                            </p:tabView> 
                        </p:panel>
                    </h:form>



                </ui:define>
            </ui:composition>
        </h:body>

    </f:view>
</html>

